import { createSlice, createAsyncThunk, PayloadAction } from "@reduxjs/toolkit";

interface UserState {
  isLogin: boolean;
  nickname: string | null;
  avator: string | null;
  token: string | null;
}
const initialState: UserState = {
  isLogin: false,
  nickname: null,
  avator: null,
  token: null,
};

const userSlice = createSlice({
  name: "user",
  initialState,
  reducers: {
    setUser(state, action: PayloadAction<UserState>) {
      state.isLogin = action.payload.isLogin
      state.nickname = action.payload.nickname
      state.avator = action.payload.avator
      state.token = action.payload.token
    }
  },
});
export const { setUser } = userSlice.actions

export default userSlice.reducer
